<?php
    $cs = Yii::app()->getClientScript();
    
    $cs->registerScriptFile(Html::jsUrl('user.js'));
?>
<?php $this->beginContent('/layouts/main'); ?>

<div id="message-drawer" class="alert-messages hidden">
    <div class="message ">
        <div class="message-inside">
            <span class="message-text"></span><a href="#" class="dismiss">×</a>
        </div>
    </div>
</div>

<?php
    $username = Yii::app()->request->getParam('u');
    $user = Users::model()->with()->find(array(
        'select'   => 'id, full_name',
        'condition'=> 'username = :username',
        'params'   => array(
            ':username'=>$username,
        )
    ));
    $userInfo = TweetCore::show($user->id);
?>

<script>
    var USER_FOLLOWING_URL = '<?php echo $this->createUrl('user/following',array('u'=>''))?>';
    var USER_FOLLOWER_URL  = '<?php echo $this->createUrl('user/followers',array('u'=>''))?>';
    var userInfo           =  <?php echo CJSON::encode($userInfo)?>;
</script>

<script id="userTemplate" type="text/template">
    <div class="profile-header-inner flex-module clearfix ">


        <a target="_blank" class="profile-picture" href="<%=avatar%>">
            <img class="avatar size128" alt="Books for experts" src="<%=avatar%>">
        </a>

        <div class="profile-card-inner">
            <h1 class="fullname">
                <%=full_name%>

            </h1>
            <h2 class="username">
                <span class="screen-name"><s>@</s><%=username%></span>
                <%if(follow_status == 1){%><span class="follow-status">follows you</span><%}%>

            </h2>
            <p class="bio "><%=bio%></p>
            <p class="location-and-url">
                <span class="location">

                </span>
                <span class="divider">·</span>

                <span class="url">

                    <a href="<%=website%>" rel="me nofollow" target="_blank">
                        <%=website%>
                    </a>
                </span>

            </p>
        </div>

        <div class="profile-card-actions">
            <% if (follow_status == 1) {%>
                <div class="user-actions btn-group following including">
            <% }else{%>
                <div class="user-actions btn-group not-following ">
            <% }%>        
                <button type="button" class="follow-button btn">
                    <span class="button-text follow-text"><i class="follow"></i> Follow</span>
                    <span class="button-text following-text">Following</span>
                    <span class="button-text unfollow-text">Unfollow</span>
                </button>

                <span class="user-dropdown">
                    <i class="account-arrow"></i>
                    <i class="mark-as-spam-silhouette"></i>
                    <i class="mark-as-spam-flag"></i>
                    <small class="mark-as-spam-text">Spam?</small>
                    <ul class="dropdown-menu">
                        <li class="dropdown-caret">
                            <span class="caret-outer"></span>
                            <span class="caret-inner"></span>
                        </li>
                        <li class="mention-text pretty-link dropdown-link not-blocked">Tweet to <s>@</s>books4experts</li>
                        <li class="dm-text dropdown-link">Send a Direct Message</li>
                        <li class="list-text pretty-link dropdown-link not-blocked">Add or remove from lists…</li>
                        <li class="dropdown-divider not-blocked"></li>
                        <li class="block-text pretty-link dropdown-link not-blocked">Block <s>@</s>books4experts</li>
                        <li class="unblock-text pretty-link dropdown-link">Unblock <s>@</s>books4experts</li>
                        <li class="report-spam-text pretty-link dropdown-link">Report <s>@</s>books4experts for spam</li>
                        <li class="hide-suggestion-text dropdown-link">Hide this suggestion</li>
                        <li class="dropdown-divider is-following"></li>
                        <li class="retweet-on-text dropdown-link">Turn on Retweets</li>
                        <li class="retweet-off-text dropdown-link">Turn off Retweets</li>
                        <li class="device-notifications-on-text dropdown-link">Turn on mobile notifications</li>
                        <li class="device-notifications-off-text dropdown-link">Turn off mobile notifications</li>
                    </ul>
                </span>

            </div>

            <ul class="stats js-mini-profile-stats">
                <li><a href="<%=USER_URL+username%>" class="js-nav">

                        <strong><%=tweets_count%></strong> Tweets
                    </a></li>
                <li><a data-nav="following" data-element-term="following_stats" href="<%=USER_FOLLOWING_URL+username%>" class="js-nav">

                        <strong><%=following_count%></strong> Following
                    </a></li>
                <li><a data-nav="followers" data-element-term="follower_stats" href="<%=USER_FOLLOWER_URL+username%>" class="js-nav">

                        <strong><%=followers_count%></strong> Followers
                    </a></li>
            </ul>
        </div>
    </div>    
</script>
<div class="module profile-card component">
    
</div>
<div class="dashboard">

    <div data-component-term="profile_tweetbox" class="module component">
        <div data-screen-name="books4experts" class="profile-tweet-box flex-module">
            <div class="tweet-box-title">
                <h2>Tweet to <?php echo $user->full_name?></h2>
            </div>
            <form class="tweet-form">
                <div class="tweet-content">
                    <textarea class="tweet-box" dir="ltr"></textarea>
                </div>
          
                <div class="tweet-box-extras">
          
                    <div class="photo-selector">
                        <button tabindex="-1" type="button" class="btn">
                            <i class="tweet-camera"></i>
                        </button>
                    </div>
                </div>
                <div class="tweet-button">
                    <span class="tweet-counter">127</span>
                    <button type="button" class="btn primary-btn tweet-action disabled">Tweet</button>
                </div>
            </form>
        </div>
    </div>

    <div class="component">
        <div class="module profile-nav">
            <ul class="js-nav-links">
                <li class="<?php echo ($this->action->id == 'index')?'active':''?>">
                    <a data-nav="profile"   href="<?php echo $this->createUrl('/user/index',array('u'=>$username))?>" class="list-link">Tweets<i class="chev-right"></i></a>
                </li>
                <li class="<?php echo ($this->action->id == 'following')?'active':''?>">
                    <a data-nav="following" href="<?php echo $this->createUrl('/user/following',array('u'=>$username))?>" class="list-link">Following<i class="chev-right"></i></a>
                </li>
                <li class="<?php echo ($this->action->id == 'followers')?'active':''?>">
                    <a data-nav="followers" href="<?php echo $this->createUrl('/user/followers',array('u'=>$username))?>" class="list-link">Followers<i class="chev-right"></i></a>
                </li>
            </ul>
        </div>
    </div>


    <div class="module site-footer ">
        <div class="flex-module">
            <div class="flex-module-inner js-items-container">
                <ul class="clearfix">
                    <li class="copyright">&copy; 2012 Twitter</li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">Help</a></li>
                    <li><a href="#">Terms</a></li>
                    <li><a href="#">Privacy</a></li>
                    <li><a href="#">Blog</a></li>
                    <li><a href="#">Status</a></li>
                    <li><a href="#">Apps</a></li>
                    <li><a href="#">Resources</a></li>
                    <li><a href="#">Jobs</a></li>
                    <li><a href="#">Advertisers</a></li>
                    <li><a href="#">Businesses</a></li>
                    <li><a href="#">Media</a></li>
                    <li><a href="#">Developers</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

<div id="suggested-users" class="component"></div>
<?php echo $content ?>
<?php $this->endContent(); ?>